home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11573 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: goanna.cs.rmit.EDU.AU!not-for-mail
  2. From: ok@goanna.cs.rmit.EDU.AU (Richard A. O'Keefe)
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
  4. Subject: Re: C/C++ knocks the crap out of Ada
  5. Date: 15 Mar 1996 15:06:01 +1100
  6. Organization: Comp Sci, RMIT, Melbourne, Australia
  7. Message-ID: <4iaqb9$3gi@goanna.cs.rmit.EDU.AU>
  8. References: <00001a73+00002504@msn.com> <3146E324.5C1E@lfwc.lockheed.com> <4i98gg$8n1@solutions.solon.com> <Do9tMv.2p3@world.std.com> <4ia41k$e04@solutions.solon.com>
  9. NNTP-Posting-Host: goanna.cs.rmit.edu.au
  10. X-Newsreader: NN version 6.5.0 #0 (NOV)
  11.  
  12. seebs@solutions.solon.com (Peter Seebach) writes:
  13. >In article <Do9tMv.2p3@world.std.com>,
  14. >Robert A Duff <bobduff@world.std.com> wrote:
  15. >>The problem
  16. >>with 'make' is that you have to type in the dependences by hand.
  17.  
  18. >Not always; there is a program which does this, although I personally never
  19. >use it.
  20.  
  21. For what it's worth, the tool I currently use to build the dependencies
  22. for C files is called a C compiler.  From the SPARCompiler CC manual page:
  23.  
  24.      -xM  Runs the ANSI preprocessor on the  named  C  programs,
  25.           generates makefile dependencies and sends the result to
  26.           the standard output  (see  make(1)  for  details  about
  27.           makefiles  and  dependencies). ...
  28.  
  29.      -xM1 Same as -xM except that -xM1 does not report dependen-
  30.           cies for /usr/include header files.
  31.  
  32. From the GNU CC manual page:
  33.  
  34.      -M  [ -MG ]
  35.           Tell the preprocessor to output  a  rule  suitable  for
  36.           make  describing  the dependencies of each object file.
  37.           For each source  file,  the  preprocessor  outputs  one
  38.           make-rule whose target is the object file name for that
  39.           source file and whose dependencies are  all  the  files
  40.           `#include'd  in  it.  This rule may be a single line or
  41.           may be continued with `\'-newline if it is  long.   The
  42.           list  of rules is printed on standard output instead of
  43.           the preprocessed C program.  ...
  44.  
  45.           `-MG' says to treat missing header files  as  generated
  46.           files and assume they live in the same directory as the
  47.           source file.  It must be specified in addition to `-M'.
  48.  
  49.      -MM  [ -MG ]
  50.           Like `-M' but the output mentions only the user  header
  51.           files  included  with  `#include file"'.  System header
  52.           files included with `#include <file>' are omitted.
  53.  
  54.       ...
  55.  
  56. Even lcc's preprocessor supports this.  Basically, your makefile has
  57.  
  58.     c_dependencies: $(C_SRCS)
  59.         cc -xM1 $(C_SRCS) >$@
  60.  
  61.     include c_dependencies
  62.  
  63. The point here is that *make* doesn't know how to analyse C, or any
  64. other language or mixture of languages, but it *can* be told the results
  65. of such an analysis.
  66. -- 
  67. The election is over, and Australia lost; the idjits elected _politicians_!
  68. Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
  69.